 //*********************************************************
 // PP57.java                    Author:20172323wyh
 //*********************************************************
 
 import java.util.*;

 public class PP57
 {
     public static void main(String[] args)
     {  
        int a;
        int win = 0, lose = 0, draw = 0;
        String b, another = "y";
        ArrayList<String> game = new ArrayList<String>();

        game.add("Rock");
        game.add("Paper");
        game.add("Scissors");
  
        Random generator = new Random();
        while (another.equalsIgnoreCase("y"))
            {
              a = generator.nextInt(3);
              b = game.get(a);

            String str;
            Scanner scan = new Scanner(System.in);
            System.out.println("Enter 'Rock, Paper or Scissors' ");
            str = scan.nextLine();

            System.out.println("Your choice:" + str);

            if (b.equals(str))
              {
                System.out.println();
                System.out.println("draw");
                draw++;
              }
            else
               {
                 if( (str.equals("Rock") && b.equals("Scissors")) ||
                    (str.equals("Scissors") && b.equals("Paper")) ||
                    (str.equals("Paper") && b.equals("Rock")) )
                  { System.out.println("You win the game! Well done.");
                  win++;}
                 else
                  System.out.println("You lose the game. Try again.");
                  lose++;
               }
        
         System.out.println();
         System.out.println("The computer choose: " + b);
         System.out.print("New game(y/n)?");
         another = scan.nextLine();
         }
       System.out.println();
       System.out.println("You win in total: " + win);
       System.out.println("You lose in total: " + lose);
       System.out.println("You draw in total: " + draw);
      }
 }
